<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01-金字塔</title>
</head>
<body>
    <script>
        /*
           *
           **
           ***
           ****
           *****

                *
               **
              ***
             ****
            *****
       */
        /* 
            1111*
            111**
            11***
            1****
            *****
            11111
            1111
            111
            11
            1
            *
            **
            ***
            ****
            *****
        */
        /* 
             i           j
             0           5
             1           4
             2           3
             3           2
             4           1
             i + j = 5;
             j = 5 - i;
 
             i           j
             0           1
             1           2
             2           3
 
             i + 1 = j
        */

        for (let i = 0; i<5; i++){
            let star = '';
            let star1 = '';
            for(let j = 0; j<5-i; j++){
                //star =star +'';
                star = star + '';
            }
            for(let j = 0; j< i+1; j++){
                star1 = star1 + '*';
            }
            console.log(star + star1);
        }
    </script>
</body>
</html>